import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _class;

import React from 'react';
import { Bind } from 'lodash-decorators';
import { Tag } from 'antd';
import intl from "../../../utils/intl";
/**
 * 阻止事件冒泡
 * 在这里是: 关闭事件 需要阻止冒泡 避免触发 打开事件
 * @param {React.SyntheticEvent} e
 */

function eventStopPropagation(e) {
  e.stopPropagation();
}

var HistoryItem = (_dec = Bind(), _dec2 = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(HistoryItem, _React$Component);

  var _super = _createSuper(HistoryItem);

  function HistoryItem(props) {
    var _this;

    _classCallCheck(this, HistoryItem);

    _this = _super.call(this, props);
    _this.state = {};
    return _this;
  }
  /**
   * 通过搜索历史 跳转页面
   */


  _createClass(HistoryItem, [{
    key: "handleHistoryItemClick",
    value: function handleHistoryItemClick() {
      var _this$props = this.props,
          onClick = _this$props.onClick,
          item = _this$props.item;
      onClick(item);
    }
    /**
     * 清除一个历史记录
     */

  }, {
    key: "handleHistoryClose",
    value: function handleHistoryClose() {
      var _this$props2 = this.props,
          item = _this$props2.item,
          onCloseClick = _this$props2.onCloseClick;
      onCloseClick(item);
    }
  }, {
    key: "render",
    value: function render() {
      var item = this.props.item;
      return item.name ? /*#__PURE__*/React.createElement(Tag, {
        closable: true,
        onClick: this.handleHistoryItemClick,
        onClose: eventStopPropagation,
        afterClose: this.handleHistoryClose
      }, intl.get(item.name)) : null;
    }
  }]);

  return HistoryItem;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "handleHistoryItemClick", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleHistoryItemClick"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleHistoryClose", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "handleHistoryClose"), _class.prototype)), _class));
export { HistoryItem as default };